#include <iostream>
#include <cstring>

using namespace std;

#define MAX 1000

int dp[MAX][MAX];
int nums[MAX];

int Sum(int n, int sum)
{
    if (sum < 0)
        return 0;

    if (n == 1)
    {
        if (sum == 0 || nums[n - 1] == sum)
            return 1;
        return 0;
    }
    else
    {
        dp[n][sum] = Sum(n - 1, sum) + Sum(n - 1, sum - nums[n - 1]);
        return dp[n][sum];
    }
}

int main()
{
    int n, sum;

    while (true)
    {
        memset(dp, 0, sizeof(int) * MAX * MAX);
        memset(nums, 0, sizeof(int) * MAX);

        cout << "请输入正整数数量n=";
        cin >> n;

        cout << "请输入数字和sum=";
        cin >> sum;

        cout << "请输入" << n << "个正整数" << endl;
        for (int i = 0; i < n; i++)
            cin >> nums[i];

        cout << "和为" << sum << "的方案有" << Sum(n, sum) << "种" << endl;
    }
}